package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.Permission;
import com.itheima.service.LkPermissionService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author likun
 * @version V1.0
 * @date 2020/3/10 12:12
 */
@RestController
@RequestMapping("/permission")
public class LkPermissionController {
    @Reference
    private LkPermissionService permissionService;
    @RequestMapping("/findAllPermission")
    public Result findAllPermission(){
        try{

            List<Permission> allPermission = permissionService.findAllPermission();
            return new Result(true,MessageConstant.QUERY_PERMISSION_LIST_SUCCESS,allPermission);
        } catch (Exception e){

            return new Result(false, MessageConstant.QUERY_PERMISSION_LIST_FAIL);
        }
    }
    @RequestMapping("/findPermissionIds")
    public Result findPermissionIds(Integer id){
        try{
            List<Integer> permissionIds = permissionService.findPermissionIds(id);
            return new Result(true,MessageConstant.QUERY_PERMISSION_SUCCESS,permissionIds);
        } catch (Exception e){

            return new Result(false,MessageConstant.QUERY_PERMISSION_FAIL);
        }
    }
}
